###############################################
#
#       易码【KRTS】抖动测量
#       时间： 2024-11-11
#       版本： 1.0.0
#       代码规范： Google 开源项目风格
#       版权所有： 山东易码智能科技股份有限公司
#
###############################################

cmake_minimum_required(VERSION 3.27)
set (AppVersion "1.0.0")
project(EzCodeJitterMeasure VERSION ${AppVersion} LANGUAGES CXX )

# C++标准
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 定义系统类型
if (WIN32)
    set(OS_TYPE "Windows")
else ()
    set(OS_TYPE "Linux")
endif ()

# CMAKE中定制版本，并注入到宏中
add_definitions(
        -DFRAME_ANALYSER_VER="${AppVersion}"
        -D_CRT_SECURE_NO_WARNINGS
)

# 取消CMake默认生成的工程选项，仅保留Debug与Release（只对msvc这样的多样化构建ide有效）
if (MSVC)
    if(CMAKE_CONFIGURATION_TYPES)
        set(CMAKE_CONFIGURATION_TYPES Debug Release)
        set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
                "Reset the configurations to what we need"
                FORCE)
    endif()
endif()

# 默认设置编译选项 MSVC需要设置编译选项
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug")
endif()

# 定义构建类型
if(CMAKE_BUILD_TYPE MATCHES "Debug")
    set(BUILD_TYPE "Debug")
else()
    set(BUILD_TYPE "Release")

    # Release 设置代码运行优化
    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()

# 设置库输出路径
set(BUILD_BIN_DIR "${CMAKE_SOURCE_DIR}/Bin/${OS_TYPE}${BUILD_TYPE}")
set(BUILD_LIB_DIR "${CMAKE_SOURCE_DIR}/Lib/${OS_TYPE}${BUILD_TYPE}")

# 配置生成的执行文件、动态库、静态库保存位置
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_LIB_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_LIB_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_BIN_DIR})

#################################################################################

# 设置Kithara库路径,根据自己的库自行调整
set(KRTS_DEV_PATH "C:/Program Files/Kithara/RealTime Suite Demo/dev")
set(CUSTOM_NAME "KrtsDemo")
set(CUSTOM_NUMBER "DEMO")

#################################################################################

set(KRTS_LIB "${CUSTOM_NAME}_x64")
add_definitions(-DKRTS_HEAD=<${CUSTOM_NAME}.h> -DCUSTOM_NUMBER="${CUSTOM_NUMBER}")
include_directories("${KRTS_DEV_PATH}")
link_directories("${KRTS_DEV_PATH}")

# 设置编码格式为utf-8
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

# 引入本项目的头文件 Lib库
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
link_directories("${BUILD_LIB_DIR}")

# 程序集
add_subdirectory(App)
add_subdirectory(kernel)
add_dependencies(JitterMeasure Kernel)

